package com.ruixi.spring.jdbcTemplete.service;

import com.ruixi.spring.jdbcTemplete.entity.Book;
import com.ruixi.spring.jdbcTemplete.mapper.BookMapper;
import com.ruixi.spring.jdbcTemplete.mapper.BookMapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("bookService")
public class BookServiceImpl implements BookService {

    @Autowired
    @Qualifier("bookMapperImpl")
    BookMapperImpl bookMapperImpl;

    //添加
    @Override
    public void add(Book book) {
        this.bookMapperImpl.add(book);
    }

    //修改
    @Override
    public void update(Book book) {
        this.bookMapperImpl.update(book);
    }

    //删除
    @Override
    public void delete(String id) {
        this.bookMapperImpl.delete(id);
    }

    //查询 返回某个值
    @Override
    public Integer findCount() {
        return this.bookMapperImpl.findCount();
    }

    //查询 返回对象
    @Override
    public Book findByID(String id) {
        return this.bookMapperImpl.findByID(id);
    }

    //查询 返回集合
    @Override
    public List<Book> findAll() {
        return this.bookMapperImpl.findAll();
    }

    //批量添加
    @Override
    public void saveBatch(List<Object[]> list) {
        this.bookMapperImpl.saveBatch(list);
    }

    //批量修改
    @Override
    public void updateBatch(List<Object[]> list) {
        this.bookMapperImpl.updateBatch(list);
    }

    //批量删除
    @Override
    public void deleteBatch(List<Object[]> list) {
        this.bookMapperImpl.deleteBatch(list);
    }

}
